package edu.sctu.practice.class02.hujie.my_practice.day20151119collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

/**
 * Created by hp on 2015/12/4
 */
public class A {
    public void testSort1() {
        List<Integer> integerList = new ArrayList<Integer>();
        //插入十个100以内的不重复随机整数
        Random random = new Random();
        Integer k;
        for (int i = 0; i < 10; i++) {
            do {
                k = random.nextInt(100);
            } while (integerList.contains(k));
            integerList.add(k);
            System.out.println("成功添加整数：" + k);
        }


        System.out.println("********排序前***********");
        for (Integer integer : integerList) {
            System.out.println("元素：" + integer);
        }
        Collections.sort(integerList);
        System.out.println("********排序后***********");
        for (Integer integer : integerList) {
            System.out.println("元素：" + integer);
        }
    }
    public static void main(String[] args) {
        A t = new A();
        t.testSort1();
    }
}
